package cn.sc.summer.gateway.runner;

import cn.sc.summer.redis.util.NacosInstancesService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextClosedEvent;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Component;

/**
 * 类名：auth启动执行
 *
 * @author a-xin
 * @date 2023/8/25 14:31
 */
@Slf4j
@Component
public class GatewayFeignRunner implements CommandLineRunner, ApplicationListener<ContextClosedEvent> {

    @Override
    public void run(String... args) {
    }

    @Override
    public void onApplicationEvent(@NonNull ContextClosedEvent event) {
        if (NacosInstancesService.isLastInstance()) {
            //当该服务为最后一个服务时需要执行的逻辑
        }
    }

}
